package Demo;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/9
 * Time: 18:11
 * Description: No Description
 */
class Student {
    public String name;
    public int age;
    public double score;

    public Student(String name, int age, double score) {
        this.age = age;
        this.name = name;
        this.score = score;

    }



    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }
}

class cmp implements Comparator<Integer> {

    //整形排序
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2 - o1;
    }

   /* //字符排序
    public int compare(Student o1,Student o2) {
        return o1.name.compareTo(o2.name);
    }

    //小数排序
    public int compare(Student o1,Student o2) {
        return (int)(o1.score - o2.score);
    }*/
}
public class TestDemo {



    public static void main(String[] args) {
        Integer[] array = {5,8,7,6,3,2,1,4};

        cmp c= new cmp();
        Arrays.sort(array,c);
        System.out.println(Arrays.toString(array));
    }
    /*public static void main1(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student("zhangsan",29,88);
        student[1] = new Student("lisi",20,66);
        student[2] = new Student("wangwu",25,13);

        IntComparator intcomparator = new IntComparator();
        Arrays.sort(student,intcomparator);
        System.out.println(Arrays.toString(student));
    }*/
}